<?php

namespace app\admin\model\finance\extract;

use think\Model;

class User extends Model
{
    // 表名
    protected $name = 'finance_extract_user';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    
    // 追加属性
    protected $append = [
        'status_text',
		'position_text',
		'username_text',
        'avatar_text',
    ];
    
   /**
     * 讲师头像
     */
    public function getAvatarTextAttr($value, $data){
        $value = $value ? $value : $data['userid'];
        $avatar = TableField('Admin','thumb_avatar',$value,'userid');
        $avatar = $avatar ? $avatar : TableField('Admin','avatar',$value,'userid');
        $avatar = $avatar ? $avatar : '/dailybill/img/jia.png';
        return $avatar;
    }   
    
    public function getStatusList()
    {
        return ['1' => __('User.Status 1'),'2' => __('User.Status 2')];
    }     


    public function getStatusTextAttr($value, $data)
    {        
		
        $value = $value ? $value : $data['status'];
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }
    public function getPositionTextAttr($value, $data)
    {   
        $value = $value ? $value : $data['position'];
		if($value = explode(',',$value)){
			if($value = GetExplode($value,'AuthGroup')){
				return $value;
			}	
			
		}
		return '';
    }
	 public function getUsernameTextAttr($value, $data){   
        $value = $value ? $value : $data['userid'];
		return TableField('Admin','username',$value,'userid');
    }




}
